package C06.E3;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.Objects;

public class E3 {
    public static void main(String[] args) {
        //迭代器 Iterator 遍历集合
        ArrayList list = new ArrayList();
        list.add("张森");
        list.add("贾多多");
        list.add("孟小格");
        list.add("郭圈圈");
        list.add(Math.PI);
        Iterator it = list .iterator();//返回一个list对象的迭代器
        while(it.hasNext()){
            Object obj = it.next();
            System.out.println(obj);
        }
        System.out.println("for循环迭代集合");

        for (Object obj:list){
            System.out.println(obj);
        }
    }
}
